angular.module('wenews.service', []).factory('$localstorage', ['$window',
    function ($window) {
        return {
            set: function (key, value) {
                $window.localStorage[key] = value;
            },
            get: function (key, defaultValue) {
                return $window.localStorage[key] || defaultValue;
            },
            setObject: function (key, value) {
                $window.localStorage[key] = JSON.stringify(value);
            },
            getObject: function (key) {
                return JSON.parse($window.localStorage[key] || '{}');
            },
            setList: function (key, value) {
                $window.localStorage[key] = JSON.stringify(value);
            },
            getList: function (key) {
                return JSON.parse($window.localStorage[key] || '[]');
            },
            clear: function () {
                $window.localStorage.clear();
            }
        }
    }
]).factory('Util', function ($ionicLoading) {
    return {
        toast: function (message, time) {
            $ionicLoading.show({
                template: '<span class="icon spin ion-ios7-information-outline"></span> ' + message,
                noBackdrop: true,
                duration: time
            });
        },
        loading: function (message, time) {
            $ionicLoading.show({
                template: '<span class="icon spin ion-ios7-information-outline"></span> ' + message,
                duration: time
            });
        },
        checkUpdate: function () {

        }
    }
});